import {BrowserModule} from '@angular/platform-browser';
import {NgModule, APP_INITIALIZER} from '@angular/core';
import {Router} from '@angular/router';

import {AppComponent} from './app.component';
// http拦截器
import {httpInterceptorProviders} from './http-interceptors';
// 判断是否是生产模式
import {environment} from '../environments/environment';
// 主路由模块
import {AppRoutingModule} from './app-routing.module';
// 引入core模块
import {CoreModule} from './core/core.module';
// 引入config模块
import {ConfigModule} from './config/config.module';
// 引入路由复用策略
import {RouteReuseStrategy} from '@angular/router';
import {KylinRouteReuseStrategy} from './core/service/kylinRouteReuseStrategy';
// ng-zorro需要的依赖
import {FormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
/** 配置 angular i18n **/
import {registerLocaleData} from '@angular/common';
import zh from '@angular/common/locales/zh';


registerLocaleData(zh);

// 注意: imports AppRoutingModule必须在最后一个(会影响路由结构的顺序)

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        HttpClientModule,
        BrowserAnimationsModule,
        NgZorroAntdModule,
        FormsModule,
        ConfigModule,
        CoreModule,
        AppRoutingModule,

    ],
    providers: [
        httpInterceptorProviders,
        {provide: RouteReuseStrategy, useClass: KylinRouteReuseStrategy},
        {provide: NZ_I18N, useValue: zh_CN},
        {
            provide: APP_INITIALIZER,
            useFactory: () => {
                return () => {
                    return new Promise((resolve, reject) => {
                        resolve();
                    });
                }
            },
            multi: true
        }
    ],
    bootstrap: [AppComponent]
})
export class AppModule {
    constructor(router: Router) {
        // 如果当前环境是生产环境,那么就不在控制台打印路由结构
        if (!environment.production) {
            // console.log('Routes: ', JSON.stringify(router.config, undefined, 2));
        }
    }
}
